<%@page import="javax.portlet.PortletPreferences"%>
<%@page import="org.w3c.dom.NodeList"%>
<%@page import="org.w3c.dom.Element"%>
<%@page import="org.w3c.dom.Document"%>
<%@page import="java.io.InputStream"%>
<%@page import="java.net.URL"%>
<%@page import="javax.xml.parsers.DocumentBuilder"%>
<%@page import="javax.xml.parsers.DocumentBuilderFactory"%>
<%
/**
 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */
%>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />
<h1 style="border-bottom: 2px dotted #ccc;">Avisos</h1>	
<portlet:renderURL var="showAvisosURL">
				<portlet:param name="jspPage" value="/view.jsp"/>
</portlet:renderURL>
<div style="width: 100%; text-align: right;">
<a href="<%= showAvisosURL %>"><img src="/image-proxy/btn_back.png"/></a>
</div>

<%


DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(false);
DocumentBuilder docBuilder = dbf.newDocumentBuilder();

URL avisoURL = new URL("http://10.52.152.2/eventos/avisos/" +
		renderRequest.getParameter("avisoId") + ".xml");
InputStream isAviso = avisoURL.openStream();

Document docAviso = docBuilder.parse(isAviso);
Element avisoTag = docAviso.getDocumentElement();
%>
<p>
	<h2><%= avisoTag.getElementsByTagName("titulo").item(0).getTextContent() %></h2>
</p>
<p>
<%= avisoTag.getElementsByTagName("texto").item(0).getTextContent() %>
</p>

<p>
	<% if(! avisoTag.getElementsByTagName("filename").item(0).getTextContent().isEmpty()){ %>
	<a target="_blank" href="http://www.pame.intraer/eventos/recursos/<%= avisoTag.getElementsByTagName("filename").item(0).getTextContent() %>">Baixar</a>
	<% } %>
</p>

<div style="width: 100%; text-align: right;">
<a href="<%= showAvisosURL %>"><img src="/image-proxy/btn_back.png"/></a>
</div>


